// pages/AbnormalList/AbnormalList.js
Page({

    /**
     * 页面的初始数据
     */
    data: {
        show:false,
        columns: ['全部', '已处理', '待处理'],
        user:wx.getStorageSync('userDetail')
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
      var _that=this
      wx.request({
        url: 'http://192.168.31.166/Wx/abnormalHistory',
        method:'post',
        header:{
          "Content-Type": "application/x-www-form-urlencoded"
        },
        data:{
          openid:wx.getStorageSync('openid'),
        },
        success(res){
          if(res.data.code==200){
            _that.setData({
              data:res.data.data
            })
          }else{

          }
        }
      })
    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {

    },
    BtnPop() {
        this.setData({ show: true });
        console.log("点击")
      },
    
      onConfirm(event) {
        var _that=this
        const { picker, value, index } = event.detail;
        console.log("value:"+value+" .index:"+index)
        if(index==0){
        wx.request({
          url: 'http://192.168.31.166/Wx/abnormalHistory',
          method:'post',
          header:{
            "Content-Type": "application/x-www-form-urlencoded"
          },
          data:{
            openid:wx.getStorageSync('openid'),
          },
          success(res){
            if(res.data.code==200){
              _that.setData({
                data:res.data.data,
                show:false
              })
            }else{
  
            }
          }
        })
      }
      if(index==1){
        wx.request({
          url: 'http://192.168.31.166/Wx/abnormalHistory',
          method:'post',
          header:{
            "Content-Type": "application/x-www-form-urlencoded"
          },
          data:{
            openid:wx.getStorageSync('openid'),
            status:1
          },
          success(res){
            if(res.data.code==200){
              _that.setData({
                data:res.data.data,
                show:false
              })
            }else{
  
            }
          }
        })
      }
      if(index==2){
        wx.request({
          url: 'http://192.168.31.166/Wx/abnormalHistory',
          method:'post',
          header:{
            "Content-Type": "application/x-www-form-urlencoded"
          },
          data:{
            openid:wx.getStorageSync('openid'),
            status:0
          },
          success(res){
            if(res.data.code==200){
              _that.setData({
                data:res.data.data,
                show:false
              })
            }else{
  
            }
          }
        })
      }
    },
    
      onCancel() {
        this.setData({show:false})
      },

      onClickView(e){
        console.log(e)
        wx.navigateTo({
          url: './AbnormalView/AbnormalView?id='+e.currentTarget.dataset.index,
        })
      }
})